#ifndef __CAMERA_H__
#define __CAMERA_H__

#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

enum CAMERA_DIRECTION {
    FORWARD,
    BACKWARD,
    LEFT,
    RIGHT
};
// Default camera values
const float YAW         = -90.0f;
const float PITCH       =  0.0f;
const float SPEED       =  2.5f;
const float SENSITIVITY =  0.1f;
const float ZOOM        =  45.0f;

class Camera {
    public:
        glm::vec3 Position;
        glm::vec3 Front;
        glm::vec3 Right;
        glm::vec3 Up;
        glm::vec3 WorldUp;
        
        // 偏航角
        float yaw;
        // 俯仰角
        float pitch;
        // 移动速度
        float moveSpeed;
        // 鼠标灵敏度
        float mouseSensivity;
        // 视野角度
        float zoom;
        
        Camera(glm::vec3 position=glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 up=glm::vec3(0.0f, 1.0f, 0.0f), float yaw=YAW, float pitch = PITCH): Front(glm::vec3(0.0f, 0.0f, -1.0f)), moveSpeed(SPEED), mouseSensivity(SENSITIVITY), zoom(ZOOM) {
            Position = position;
            WorldUp = up;
            this->yaw = yaw;
            this->pitch = pitch;
            updateCamera();
        }
        Camera(float pX, float pY, float pZ, float uX, float uY, float uZ, float yaw=YAW, float pitch = PITCH): Front(glm::vec3(0.0f, 0.0f, -1.0f)), moveSpeed(SPEED), mouseSensivity(SENSITIVITY), zoom(ZOOM) {
            Position = glm::vec3(pX, pY, pZ);
            WorldUp = glm::vec3(uX, uY, uZ);
            this->yaw = yaw;
            this->pitch = pitch;
            updateCamera();
        }
        glm::mat4 getView();
        
        void processKey(CAMERA_DIRECTION direction, float deltaTime);

        void round(float xoffset, float yoffset);

        void scroll(double yoffset);
    private:
        void updateCamera();
};


#endif